<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>校园宿舍管理系统 - 添加宿舍</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  <style>
    body {
      background-color: #f8f9fa;
    }
    .card {
      box-shadow: 0 4px 8px rgba(0,0,0,0.05);
      border-radius: 10px;
    }
    .form-label {
      font-weight: 600;
    }
    .form-text {
      font-size: 0.85em;
      color: #6c757d;
    }
    .btn-primary {
      background-color: #17a589;
      border: none;
    }
    .btn-secondary {
      background-color: #adb5bd;
      border: none;
    }
    .navbar-dark {
      background-color: #17a589 !important;
    }
  </style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark" style="background-color: #17a589;">
  <div class="container">
    <a class="navbar-brand" href="#">校园宿舍管理系统</a>
    <div class="collapse navbar-collapse">
      <ul class="navbar-nav me-auto">
        <li class="nav-item">
          <a class="nav-link" th:href="@{/home}">首页</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" th:href="@{/student/list}">学生管理</a>
        </li>
        <li class="nav-item">
          <a class="nav-link active" th:href="@{/dormitory/list}">宿舍管理</a>
        </li>
      </ul>
      <div class="d-flex">
        <span class="navbar-text me-3" th:text="'欢迎，' + ${session.user.username}"></span>
        <a class="btn btn-outline-light" th:href="@{/user/logout}">退出</a>
      </div>
    </div>
  </div>
</nav>

<div class="container mt-5">
  <div class="row justify-content-center">
    <div class="col-md-8">
      <div class="card border-0">
        <div class="card-header bg-white py-4">
          <h4 class="text-center mb-0">添加宿舍信息</h4>
        </div>
        <div class="card-body p-4">
          <form th:action="@{/dormitory/add}" method="post">
            <div class="row">
              <div class="col-md-6 mb-3">
                <label for="dormitoryNumber" class="form-label">宿舍号</label>
                <input type="text" class="form-control form-control-lg" id="dormitoryNumber" name="dormitoryNumber" required>
              </div>
              <div class="col-md-6 mb-3">
                <label for="building" class="form-label">宿舍楼</label>
                <input type="text" class="form-control form-control-lg" id="building" name="building" required>
              </div>
            </div>

            <div class="row">
              <div class="col-md-6 mb-3">
                <label for="floor" class="form-label">楼层</label>
                <input type="number" class="form-control form-control-lg" id="floor" name="floor" required min="1">
              </div>
              <div class="col-md-6 mb-3">
                <label for="capacity" class="form-label">容量</label>
                <input type="number" class="form-control form-control-lg" id="capacity" name="capacity" required min="1">
                <div class="form-text mt-1">该宿舍最多可入住人数</div>
              </div>
            </div>

            <div class="mb-4">
              <label for="type" class="form-label">宿舍类型</label>
              <input type="text" class="form-control form-control-lg" id="type" name="type" required>
              <div class="form-text mt-1">例如: 四人间, 二人间</div>
            </div>

            <div class="d-grid gap-2 d-md-flex justify-content-md-end">
              <button type="submit" class="btn btn-primary btn-lg px-4">提交</button>
              <a th:href="@{/dormitory/list}" class="btn btn-secondary btn-lg px-4">取消</a>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
</body>
</html>